<template>
  <a-modal title="新增" :visible="visible" ok-text="确定" @ok="handleSubmit" @cancel="handleCancel">
    <a-form-model ref="form" :model="queryParam" :rules="validatorRules">
      <a-form-model-item label="请选择考核模版" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="id">
        <a-select v-model="queryParam.id" placeholder="请选择考核模版">
          <a-select-option v-for="item in tempList" :key="item.id" :value="item.id">
            {{ item.templateName }}
          </a-select-option>
        </a-select>
      </a-form-model-item>
    </a-form-model>
  </a-modal>
</template>

<script>
import moment from 'moment'
import { httpAction, getAction, postAction, deleteAction } from '@/api/manage'
export default {
  name: 'addTemp',
  components: {},
  data() {
    return {
      queryParam: {
        id: '',
      },
      visible: false,
      validatorRules: {
          id: [{required: true, message: '请选择考核模版'}],
        //   quarter: [{required: true, message: '请输入季度!'}]
      },
      tempList: [],
      labelCol: {
        xs: { span: 24 },
        sm: { span: 7 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      approverList: '',
      url: {
        getApprover: '/sys/user/queryAuditInfoByOrgCode',
        temp: '/performcheck/checkTemplateInfo/queryTemplateMenu',
      },
    }
  },
  created() {},
  mounted() {
    this.getTempList()
  },
  methods: {
    async getTempList() {
      const { result } = await getAction(this.url.temp)
      this.tempList = result
    },
    handleSubmit() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.visible = false
          this.$emit('openModelView', this.queryParam)
          this.queryParam = {
            id: '',
          }
        } else {
          return false
        }
      })
    },
    handleCancel(e) {
      this.visible = false
    },
    moment,
    // 得到年份选择器的值
    handlePanelChange(value) {
      this.queryParam.year = moment(value).format('YYYY')
      this.yearPickShow = false
      this.$refs.form.validateField('year', (error) => {
        console.log(error)
      })
    },
    // 弹出日历和关闭日历的回调
    handleOpenChange(status) {
      this.yearPickShow = status
    },
  },
}
</script>

<style scoped>
</style>
